package persistence;

import javax.validation.constraints.NotNull;

final public class Supplier {
	private int id;
	@NotNull
	private String name;
	private long sapAccountsPayableNo;	
	private String street;
	@NotNull //necessary, because same supplier may f.e. have multiple subsidiaries 
	private City city;
	
	protected Supplier(){};
	
	protected Supplier(int id, String name, long sapAccountsPayableNo, String street, City city) {
		setId(id);
		setName(name);
		setSapAccountsPayableNo(sapAccountsPayableNo);
		setStreet(street);
		setCity(city);
	}
	
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Supplier: ").append(" id=").append(id).append(", name=").append(name).
		append("sapAccountsPayableNo=").append(sapAccountsPayableNo).append(", street=").append(street).append(", city=").append(city);
		
		return builder.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result
				+ (int) (sapAccountsPayableNo ^ (sapAccountsPayableNo >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Supplier other = (Supplier) obj;
		if (id != other.id)
			return false;
		if (sapAccountsPayableNo != other.sapAccountsPayableNo)
			return false;
		return true;
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}
	
	public long getSapAccountsPayableNo() {
		return sapAccountsPayableNo;
	}

	public String getStreet() {
		return street;
	}

	public City getCity() {
		return city;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void setSapAccountsPayableNo (long sapAccountsPayableNo) {
		this.sapAccountsPayableNo = sapAccountsPayableNo;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public void setCity(City city) {
		this.city = city;
	}	
}